<!--
 * @Author: byron
 * @Date: 2021-08-26 09:11:53
 * @LastEditTime: 2021-08-26 09:16:43
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>2_使用js创建虚拟dom</title>
</head>

<body>
    <!-- 准备容器 -->
    <div id="test"></div>

    <!-- 引入必要的js库 -->
    <script type="text/javascript" src="../lib/react.development.js"></script>
    <script type="text/javascript" src="../lib/react-dom.development.js"></script>
    <!-- 引入babel库进行语法转化 -->
    <!-- <script type="text/javascript" src="../lib/babel.min.js"></script> -->

    <script type="text/javascript">
        // 创建虚拟dom
        // const VDOM  = <h1>Hello React</h1>   //此处不是字符串，不要写引号
        // 使用React自带的api创建虚拟dom
        const VDOM = React.createElement('h1', {
            id: 'title'
        }, 'Hello World')
        //渲染虚拟dom到页面
        ReactDOM.render(VDOM, document.getElementById("test"))
    </script>
</body>

</html>